import json

from LLM import refine_answer
from plan import execute_plan

with open('初赛 B 榜question.json', 'r', encoding='utf-8') as f:
    lines = f.readlines()
data = [json.loads(line.strip()) for line in lines]
for q in data:
    try:
        ans = q['answer']
        continue
    except:
        question = q['question']
        print(q['id'],question)
        try:
            answer = execute_plan(question)
            answer = refine_answer(q['question'], answer)
        except:
            answer = q['question']
        q['answer'] = answer
        print(q['answer'])



with open("submission-b.json", "w", encoding="utf-8") as f:
    for item in data:
        f.write(json.dumps(item, ensure_ascii=False) + "\n")
